<?php
require_once 'models/models_binhluan.php';
$mod = $_GET['mod'];
$obbl = new models_binhluan();	
require_once 'models/models_mathang.php';
$obmh = new models_mathang();
switch ($mod){
	case 'binhluan':{
		$data['list'] = $obbl->_listbinhluan();
		$data['listmh']=$obmh->listMatHang();
		//echo var_dump($data);
		require_once 'views/admin/binhluan/index.php';
		break;
	}
	case 'addbinhluan':{
		if($_POST)
		{
			$obbl->_addbinhluan($_POST['cmb_MatHang'], $_POST['hoten'],$_POST['dienthoai'],$_POST['email'],gmdate("Y-m-d H:i:s", time()+7*3600), $_POST['noidung'],$_POST['anhien']);
			echo '<script> window.location.href="admin.php?mod=binhluan"</script>';
		}
		$data['list'] = $obbl->_listbinhluan();
		$data['listmh']=$obmh->listMatHang();
		require 'views/admin/binhluan/add.php';
		break;
	}
	case 'delbinhluan':{
		$obbl->_delbinhluan($_GET['ma']);
		echo '<script>window.location.href="admin.php?mod=binhluan"</script>';
		break;
	}
	case 'updatebinhluan':{
		if($_POST){
			$obbl->_updatebinhluan($_POST['cmb_MatHang'], $_POST['hoten'],$_POST['dienthoai'],$_POST['email'],gmdate("Y-m-d H:i:s", time()+7*3600),$_POST['noidung'], $_POST['anhien'], $_GET['ma']);
			echo '<script>window.location.href="admin.php?mod=binhluan"</script>';
		}
		$bl = $obbl->getbinhluan($_GET['ma']);
		$data['listmh']=$obmh->listMatHang();
		require 'views/admin/binhluan/edit.php';
		break;
	}
	default: {echo  'Yeu cau chua duoc xu ly !'; break;}
	}
?>